package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo05 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection()){
            Statement statement = connection.createStatement();
            String sql = "select username, password, nickname, age from userinfo";
            ResultSet r = statement.executeQuery(sql);
            while (r.next()) {
                 String username = r.getString("username");
                String password = r.getString("password");
                String nickname = r.getString("nickname");
                String age = r.getString("age");
                System.out.println(username+'\t'+password+'\t'+nickname+"\t"+age);
            }

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }


}
